package com.avic.rong.payUtil.pay.payWeiXin;

import android.content.Context;

import com.avic.rong.payUtil.PayConstant;
import com.avic.rong.payUtil.PayVo;
import com.avic.rong.payUtil.pay.WexinAliPayRsultCallBack;
import com.avic.rong.wxapi.WXPayEntryActivity;
import com.tencent.mm.opensdk.modelpay.PayReq;
import com.tencent.mm.opensdk.openapi.IWXAPI;
import com.tencent.mm.opensdk.openapi.WXAPIFactory;

public class WeixinPay implements PayConstant {
	WexinAliPayRsultCallBack mPayRsultCallBack;

	public WeixinPay(WexinAliPayRsultCallBack mPayRsultCallBack) {
		this.mPayRsultCallBack = mPayRsultCallBack;

	}

	public void sendPayReq(PayVo payVo, Context context) {
		WXPayEntryActivity.setmPayRsultCallBack(payVo.getAppid(),mPayRsultCallBack);
		PayReq req = new PayReq();
		IWXAPI msgApi = WXAPIFactory.createWXAPI(context, null);
		msgApi.registerApp(payVo.getAppid());
//		HashMap<String, String> map = new HashMap<>();
//		map = Util.getMap(sign);
//		req.appId = map.get("appid");//应用ID    微信开放平台审核通过的应用APPID
//		req.partnerId = map.get("partnerid");//商户号    微信支付分配的商户号
//		req.prepayId = map.get("prepayid");//预支付交易会话ID   微信返回的支付交易会话ID
//		req.nonceStr = map.get("noncestr");//随机字符串  随机字符串，不长于32位。
//		req.timeStamp = map.get("timestamp");//时间戳
//		req.packageValue = map.get("packagevalue");
//		req.sign = map.get("sign");//签名
		req.appId = payVo.getAppid();//应用ID    微信开放平台审核通过的应用APPID
		req.partnerId = payVo.getPartnerid();//商户号    微信支付分配的商户号
		req.prepayId = payVo.getPrepayid();//预支付交易会话ID   微信返回的支付交易会话ID
		req.nonceStr = payVo.getNoncestr();//随机字符串  随机字符串，不长于32位。
		req.timeStamp = payVo.getTimestamp();//时间戳
//		req.packageValue = "Sign=WXPay";
		req.packageValue = payVo.getPackageX();
		req.sign = payVo.getSign();//签名
		msgApi.sendReq(req);
	}

}
